package com.hgy.carsb.controller;

import com.hgy.carsb.entity.ProfitTrendDetail;
import com.hgy.carsb.service.ProfitTrendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class ProfitTrendController {

    @Autowired
    private ProfitTrendService profitTrendService;

    private int year = 2020;
    private int month = 4;

    @GetMapping("/profittrend")
    @ResponseBody
    public List<ProfitTrendDetail> getDetail(){
        List<ProfitTrendDetail> ans = new ArrayList<>();
        String[] code = {"advertising", "freight", "msalary", "promotion", "propaganda", "quality"};
        for (int i=0; i<6; i++){
            ans.add(profitTrendService.getDetail(year, month, code[i], "FAW"));
        }
        return ans;
    }
}
